{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020/09/08, 22:04:25, Iteration: 100, Train Loss: 4.7146e+01, c1: 2.0505e-02, c2: 1.5877e-02, d1: 4.3508e-01, d2: 0.0000e+00, l1_reg: 3.0655e+02, l2_reg: 4.3902e+01\n",
      "2020/09/08, 22:04:26, Iteration: 200, Train Loss: 3.6495e+01, c1: 2.5911e-02, c2: 1.5168e-01, d1: 1.8736e-01, d2: 0.0000e+00, l1_reg: 3.0955e+02, l2_reg: 4.5155e+01\n",
      "2020/09/08, 22:04:27, Iteration: 300, Train Loss: 3.2347e+01, c1: 1.6013e-02, c2: 1.6012e-01, d1: 1.4733e-01, d2: 0.0000e+00, l1_reg: 3.1071e+02, l2_reg: 4.5637e+01\n",
      "2020/09/08, 22:04:28, Iteration: 400, Train Loss: 3.0442e+01, c1: 1.6150e-02, c2: 1.4542e-01, d1: 1.4285e-01, d2: 0.0000e+00, l1_reg: 3.1067e+02, l2_reg: 4.5689e+01\n",
      "2020/09/08, 22:04:29, Iteration: 500, Train Loss: 2.8255e+01, c1: 1.1553e-02, c2: 1.3208e-01, d1: 1.3892e-01, d2: 0.0000e+00, l1_reg: 3.1064e+02, l2_reg: 4.5787e+01\n",
      "2020/09/08, 22:04:30, Iteration: 600, Train Loss: 2.6545e+01, c1: 1.0118e-02, c2: 1.1961e-01, d1: 1.3572e-01, d2: 0.0000e+00, l1_reg: 3.1057e+02, l2_reg: 4.5886e+01\n",
      "2020/09/08, 22:04:31, Iteration: 700, Train Loss: 2.8927e+01, c1: 4.7145e-02, c2: 1.0841e-01, d1: 1.3371e-01, d2: 0.0000e+00, l1_reg: 3.1011e+02, l2_reg: 4.5953e+01\n",
      "2020/09/08, 22:04:32, Iteration: 800, Train Loss: 2.6936e+01, c1: 3.8845e-02, c2: 9.8886e-02, d1: 1.3163e-01, d2: 0.0000e+00, l1_reg: 3.0978e+02, l2_reg: 4.5992e+01\n",
      "2020/09/08, 22:04:32, Iteration: 900, Train Loss: 2.2570e+01, c1: 6.5134e-03, c2: 8.9163e-02, d1: 1.3002e-01, d2: 0.0000e+00, l1_reg: 3.0955e+02, l2_reg: 4.5936e+01\n",
      "2020/09/08, 22:04:33, Iteration: 1000, Train Loss: 2.2456e+01, c1: 1.6152e-02, c2: 7.8531e-02, d1: 1.2988e-01, d2: 0.0000e+00, l1_reg: 3.0943e+02, l2_reg: 4.5830e+01\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/lib/python3.8/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
      "  return array(a, dtype, copy=False, order=order)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020/09/08, 22:04:34, Iteration: 1100, Train Loss: 2.3821e+01, c1: 3.9902e-02, c2: 6.8155e-02, d1: 1.3015e-01, d2: 0.0000e+00, l1_reg: 3.0936e+02, l2_reg: 4.5807e+01\n",
      "2020/09/08, 22:04:35, Iteration: 1200, Train Loss: 2.2376e+01, c1: 3.5423e-02, c2: 5.9191e-02, d1: 1.2914e-01, d2: 0.0000e+00, l1_reg: 3.0937e+02, l2_reg: 4.5850e+01\n",
      "2020/09/08, 22:04:36, Iteration: 1300, Train Loss: 1.9467e+01, c1: 1.8261e-02, c2: 4.7237e-02, d1: 1.2918e-01, d2: 0.0000e+00, l1_reg: 3.0959e+02, l2_reg: 4.5954e+01\n",
      "2020/09/08, 22:04:37, Iteration: 1400, Train Loss: 1.7786e+01, c1: 1.3163e-02, c2: 3.6231e-02, d1: 1.2846e-01, d2: 0.0000e+00, l1_reg: 3.1000e+02, l2_reg: 4.6097e+01\n",
      "2020/09/08, 22:04:38, Iteration: 1500, Train Loss: 2.1852e+01, c1: 6.3582e-02, c2: 2.6510e-02, d1: 1.2843e-01, d2: 0.0000e+00, l1_reg: 3.1067e+02, l2_reg: 4.6337e+01\n",
      "2020/09/08, 22:04:38, Iteration: 1600, Train Loss: 1.4649e+01, c1: 6.2022e-03, c2: 1.2719e-02, d1: 1.2757e-01, d2: 0.0000e+00, l1_reg: 3.1138e+02, l2_reg: 4.6673e+01\n",
      "2020/09/08, 22:04:39, Iteration: 1700, Train Loss: 1.5703e+01, c1: 1.3257e-02, c2: 1.6523e-02, d1: 1.2725e-01, d2: 0.0000e+00, l1_reg: 3.1187e+02, l2_reg: 4.6876e+01\n",
      "2020/09/08, 22:04:40, Iteration: 1800, Train Loss: 1.4515e+01, c1: 6.7456e-03, c2: 1.1554e-02, d1: 1.2685e-01, d2: 0.0000e+00, l1_reg: 3.1190e+02, l2_reg: 4.6934e+01\n",
      "2020/09/08, 22:04:41, Iteration: 1900, Train Loss: 1.4060e+01, c1: 1.0464e-02, c2: 3.3374e-03, d1: 1.2680e-01, d2: 0.0000e+00, l1_reg: 3.1184e+02, l2_reg: 4.6958e+01\n",
      "2020/09/08, 22:04:42, Iteration: 2000, Train Loss: 1.3679e+01, c1: 3.5264e-03, c2: 6.9538e-03, d1: 1.2631e-01, d2: 0.0000e+00, l1_reg: 3.1185e+02, l2_reg: 4.7015e+01\n",
      "2020/09/08, 22:04:43, Iteration: 2100, Train Loss: 1.3741e+01, c1: 7.4192e-03, c2: 3.8939e-03, d1: 1.2610e-01, d2: 0.0000e+00, l1_reg: 3.1186e+02, l2_reg: 4.7063e+01\n",
      "2020/09/08, 22:04:43, Iteration: 2200, Train Loss: 1.3809e+01, c1: 8.6419e-03, c2: 3.7625e-03, d1: 1.2568e-01, d2: 0.0000e+00, l1_reg: 3.1205e+02, l2_reg: 4.7164e+01\n",
      "2020/09/08, 22:04:44, Iteration: 2300, Train Loss: 1.3337e+01, c1: 5.2806e-03, c2: 2.7220e-03, d1: 1.2537e-01, d2: 0.0000e+00, l1_reg: 3.1212e+02, l2_reg: 4.7221e+01\n",
      "2020/09/08, 22:04:45, Iteration: 2400, Train Loss: 1.4483e+01, c1: 2.9919e-03, c2: 1.6750e-02, d1: 1.2509e-01, d2: 0.0000e+00, l1_reg: 3.1212e+02, l2_reg: 4.7261e+01\n",
      "2020/09/08, 22:04:46, Iteration: 2500, Train Loss: 1.3893e+01, c1: 3.9541e-03, c2: 1.0175e-02, d1: 1.2480e-01, d2: 0.0000e+00, l1_reg: 3.1219e+02, l2_reg: 4.7330e+01\n",
      "2020/09/08, 22:04:47, Iteration: 2600, Train Loss: 1.3563e+01, c1: 7.8448e-03, c2: 3.2681e-03, d1: 1.2452e-01, d2: 0.0000e+00, l1_reg: 3.1232e+02, l2_reg: 4.7412e+01\n",
      "2020/09/08, 22:04:48, Iteration: 2700, Train Loss: 1.4883e+01, c1: 2.0918e-02, c2: 3.9329e-03, d1: 1.2397e-01, d2: 0.0000e+00, l1_reg: 3.1242e+02, l2_reg: 4.7483e+01\n",
      "2020/09/08, 22:04:48, Iteration: 2800, Train Loss: 1.3831e+01, c1: 1.0215e-02, c2: 4.5740e-03, d1: 1.2352e-01, d2: 0.0000e+00, l1_reg: 3.1252e+02, l2_reg: 4.7563e+01\n",
      "2020/09/08, 22:04:49, Iteration: 2900, Train Loss: 1.3266e+01, c1: 4.3004e-03, c2: 5.2048e-03, d1: 1.2315e-01, d2: 0.0000e+00, l1_reg: 3.1261e+02, l2_reg: 4.7640e+01\n",
      "2020/09/08, 22:04:50, Iteration: 3000, Train Loss: 1.3655e+01, c1: 8.3378e-03, c2: 5.5597e-03, d1: 1.2265e-01, d2: 0.0000e+00, l1_reg: 3.1279e+02, l2_reg: 4.7728e+01\n",
      "2020/09/08, 22:04:51, Iteration: 3100, Train Loss: 1.3944e+01, c1: 6.9094e-03, c2: 1.0173e-02, d1: 1.2235e-01, d2: 0.0000e+00, l1_reg: 3.1296e+02, l2_reg: 4.7809e+01\n",
      "2020/09/08, 22:04:52, Iteration: 3200, Train Loss: 1.3437e+01, c1: 9.2606e-03, c2: 3.2274e-03, d1: 1.2188e-01, d2: 0.0000e+00, l1_reg: 3.1316e+02, l2_reg: 4.7908e+01\n",
      "2020/09/08, 22:04:53, Iteration: 3300, Train Loss: 1.2992e+01, c1: 3.7767e-03, c2: 4.4559e-03, d1: 1.2169e-01, d2: 0.0000e+00, l1_reg: 3.1328e+02, l2_reg: 4.7973e+01\n",
      "2020/09/08, 22:04:54, Iteration: 3400, Train Loss: 1.3307e+01, c1: 5.0633e-03, c2: 6.5985e-03, d1: 1.2140e-01, d2: 0.0000e+00, l1_reg: 3.1340e+02, l2_reg: 4.8026e+01\n",
      "2020/09/08, 22:04:54, Iteration: 3500, Train Loss: 1.3760e+01, c1: 1.0750e-02, c2: 6.1110e-03, d1: 1.2074e-01, d2: 0.0000e+00, l1_reg: 3.1359e+02, l2_reg: 4.8125e+01\n",
      "2020/09/08, 22:04:55, Iteration: 3600, Train Loss: 1.3255e+01, c1: 4.1651e-03, c2: 8.2970e-03, d1: 1.2009e-01, d2: 0.0000e+00, l1_reg: 3.1376e+02, l2_reg: 4.8225e+01\n",
      "2020/09/08, 22:04:56, Iteration: 3700, Train Loss: 1.3412e+01, c1: 8.1845e-03, c2: 6.2088e-03, d1: 1.1973e-01, d2: 0.0000e+00, l1_reg: 3.1395e+02, l2_reg: 4.8313e+01\n",
      "2020/09/08, 22:04:57, Iteration: 3800, Train Loss: 1.2681e+01, c1: 3.2927e-03, c2: 4.4183e-03, d1: 1.1909e-01, d2: 0.0000e+00, l1_reg: 3.1416e+02, l2_reg: 4.8425e+01\n",
      "2020/09/08, 22:04:58, Iteration: 3900, Train Loss: 1.2770e+01, c1: 3.2848e-03, c2: 5.9823e-03, d1: 1.1844e-01, d2: 0.0000e+00, l1_reg: 3.1437e+02, l2_reg: 4.8536e+01\n",
      "2020/09/08, 22:04:59, Iteration: 4000, Train Loss: 1.3507e+01, c1: 1.2522e-02, c2: 4.8386e-03, d1: 1.1771e-01, d2: 0.0000e+00, l1_reg: 3.1463e+02, l2_reg: 4.8661e+01\n",
      "2020/09/08, 22:04:59, Iteration: 4100, Train Loss: 1.2576e+01, c1: 4.7320e-03, c2: 4.0211e-03, d1: 1.1700e-01, d2: 0.0000e+00, l1_reg: 3.1491e+02, l2_reg: 4.8801e+01\n",
      "2020/09/08, 22:05:00, Iteration: 4200, Train Loss: 1.3189e+01, c1: 7.4296e-03, c2: 8.5605e-03, d1: 1.1590e-01, d2: 0.0000e+00, l1_reg: 3.1523e+02, l2_reg: 4.8959e+01\n",
      "2020/09/08, 22:05:01, Iteration: 4300, Train Loss: 1.2833e+01, c1: 8.6668e-03, c2: 4.9848e-03, d1: 1.1468e-01, d2: 0.0000e+00, l1_reg: 3.1555e+02, l2_reg: 4.9131e+01\n",
      "2020/09/08, 22:05:02, Iteration: 4400, Train Loss: 1.2360e+01, c1: 5.3844e-03, c2: 4.8987e-03, d1: 1.1332e-01, d2: 0.0000e+00, l1_reg: 3.1597e+02, l2_reg: 4.9362e+01\n",
      "2020/09/08, 22:05:03, Iteration: 4500, Train Loss: 1.2056e+01, c1: 3.8844e-03, c2: 4.1531e-03, d1: 1.1252e-01, d2: 0.0000e+00, l1_reg: 3.1637e+02, l2_reg: 4.9557e+01\n",
      "2020/09/08, 22:05:04, Iteration: 4600, Train Loss: 1.4405e+01, c1: 2.4522e-02, c2: 8.5556e-03, d1: 1.1097e-01, d2: 0.0000e+00, l1_reg: 3.1684e+02, l2_reg: 4.9805e+01\n",
      "2020/09/08, 22:05:04, Iteration: 4700, Train Loss: 1.1832e+01, c1: 5.1528e-03, c2: 4.6279e-03, d1: 1.0854e-01, d2: 0.0000e+00, l1_reg: 3.1736e+02, l2_reg: 5.0104e+01\n",
      "2020/09/08, 22:05:05, Iteration: 4800, Train Loss: 1.1733e+01, c1: 6.4096e-03, c2: 4.9098e-03, d1: 1.0601e-01, d2: 0.0000e+00, l1_reg: 3.1802e+02, l2_reg: 5.0448e+01\n",
      "2020/09/08, 22:05:06, Iteration: 4900, Train Loss: 1.1663e+01, c1: 8.4716e-03, c2: 5.5107e-03, d1: 1.0264e-01, d2: 0.0000e+00, l1_reg: 3.1882e+02, l2_reg: 5.0877e+01\n",
      "2020/09/08, 22:05:07, Iteration: 5000, Train Loss: 1.1093e+01, c1: 7.0876e-03, c2: 6.0420e-03, d1: 9.7802e-02, d2: 0.0000e+00, l1_reg: 3.1985e+02, l2_reg: 5.1413e+01\n",
      "2020/09/08, 22:05:08, Iteration: 5100, Train Loss: 1.0490e+01, c1: 7.2349e-03, c2: 7.1924e-03, d1: 9.0469e-02, d2: 0.0000e+00, l1_reg: 3.2118e+02, l2_reg: 5.2112e+01\n",
      "2020/09/08, 22:05:09, Iteration: 5200, Train Loss: 9.3480e+00, c1: 5.9517e-03, c2: 6.3774e-03, d1: 8.1151e-02, d2: 0.0000e+00, l1_reg: 3.2275e+02, l2_reg: 5.2912e+01\n",
      "2020/09/08, 22:05:10, Iteration: 5300, Train Loss: 8.8008e+00, c1: 6.2937e-03, c2: 6.2862e-03, d1: 7.5428e-02, d2: 0.0000e+00, l1_reg: 3.2411e+02, l2_reg: 5.3548e+01\n",
      "2020/09/08, 22:05:10, Iteration: 5400, Train Loss: 8.4722e+00, c1: 5.4832e-03, c2: 6.7882e-03, d1: 7.2450e-02, d2: 0.0000e+00, l1_reg: 3.2498e+02, l2_reg: 5.3997e+01\n",
      "2020/09/08, 22:05:11, Iteration: 5500, Train Loss: 1.0179e+01, c1: 1.6573e-02, c2: 1.4393e-02, d1: 7.0821e-02, d2: 0.0000e+00, l1_reg: 3.2560e+02, l2_reg: 5.4348e+01\n",
      "2020/09/08, 22:05:12, Iteration: 5600, Train Loss: 8.8504e+00, c1: 9.9799e-03, c2: 8.9442e-03, d1: 6.9580e-02, d2: 0.0000e+00, l1_reg: 3.2585e+02, l2_reg: 5.4580e+01\n",
      "2020/09/08, 22:05:13, Iteration: 5700, Train Loss: 8.9411e+00, c1: 1.1036e-02, c2: 9.6825e-03, d1: 6.8692e-02, d2: 0.0000e+00, l1_reg: 3.2607e+02, l2_reg: 5.4780e+01\n",
      "2020/09/08, 22:05:14, Iteration: 5800, Train Loss: 7.7021e+00, c1: 3.7382e-03, c2: 5.3162e-03, d1: 6.7966e-02, d2: 0.0000e+00, l1_reg: 3.2625e+02, l2_reg: 5.4924e+01\n",
      "2020/09/08, 22:05:15, Iteration: 5900, Train Loss: 7.9015e+00, c1: 7.3828e-03, c2: 4.3741e-03, d1: 6.7258e-02, d2: 0.0000e+00, l1_reg: 3.2646e+02, l2_reg: 5.5064e+01\n",
      "2020/09/08, 22:05:15, Iteration: 6000, Train Loss: 7.6709e+00, c1: 5.4685e-03, c2: 4.5882e-03, d1: 6.6652e-02, d2: 0.0000e+00, l1_reg: 3.2657e+02, l2_reg: 5.5195e+01\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020/09/08, 22:05:16, Iteration: 6100, Train Loss: 7.6736e+00, c1: 6.4274e-03, c2: 4.2085e-03, d1: 6.6100e-02, d2: 0.0000e+00, l1_reg: 3.2665e+02, l2_reg: 5.5291e+01\n",
      "2020/09/08, 22:05:17, Iteration: 6200, Train Loss: 7.9312e+00, c1: 8.0777e-03, c2: 5.4402e-03, d1: 6.5794e-02, d2: 0.0000e+00, l1_reg: 3.2677e+02, l2_reg: 5.5409e+01\n",
      "2020/09/08, 22:05:18, Iteration: 6300, Train Loss: 7.9146e+00, c1: 8.1463e-03, c2: 5.7311e-03, d1: 6.5268e-02, d2: 0.0000e+00, l1_reg: 3.2688e+02, l2_reg: 5.5528e+01\n",
      "2020/09/08, 22:05:19, Iteration: 6400, Train Loss: 7.4201e+00, c1: 5.7881e-03, c2: 3.6324e-03, d1: 6.4781e-02, d2: 0.0000e+00, l1_reg: 3.2703e+02, l2_reg: 5.5638e+01\n",
      "2020/09/08, 22:05:20, Iteration: 6500, Train Loss: 8.1409e+00, c1: 1.0300e-02, c2: 6.7409e-03, d1: 6.4367e-02, d2: 0.0000e+00, l1_reg: 3.2710e+02, l2_reg: 5.5751e+01\n",
      "2020/09/08, 22:05:20, Iteration: 6600, Train Loss: 7.7586e+00, c1: 8.5870e-03, c2: 5.0504e-03, d1: 6.3948e-02, d2: 0.0000e+00, l1_reg: 3.2721e+02, l2_reg: 5.5900e+01\n",
      "2020/09/08, 22:05:21, Iteration: 6700, Train Loss: 7.3741e+00, c1: 6.9828e-03, c2: 3.5822e-03, d1: 6.3176e-02, d2: 0.0000e+00, l1_reg: 3.2740e+02, l2_reg: 5.6035e+01\n",
      "2020/09/08, 22:05:22, Iteration: 6800, Train Loss: 7.0013e+00, c1: 3.9649e-03, c2: 3.1785e-03, d1: 6.2869e-02, d2: 0.0000e+00, l1_reg: 3.2758e+02, l2_reg: 5.6164e+01\n",
      "2020/09/08, 22:05:23, Iteration: 6900, Train Loss: 7.4206e+00, c1: 6.6032e-03, c2: 5.2422e-03, d1: 6.2360e-02, d2: 0.0000e+00, l1_reg: 3.2779e+02, l2_reg: 5.6318e+01\n",
      "2020/09/08, 22:05:24, Iteration: 7000, Train Loss: 7.6828e+00, c1: 5.6467e-03, c2: 9.2699e-03, d1: 6.1912e-02, d2: 0.0000e+00, l1_reg: 3.2793e+02, l2_reg: 5.6453e+01\n",
      "2020/09/08, 22:05:25, Iteration: 7100, Train Loss: 7.3814e+00, c1: 8.6397e-03, c2: 3.9256e-03, d1: 6.1249e-02, d2: 0.0000e+00, l1_reg: 3.2820e+02, l2_reg: 5.6618e+01\n",
      "2020/09/08, 22:05:25, Iteration: 7200, Train Loss: 7.4128e+00, c1: 9.2086e-03, c2: 3.8990e-03, d1: 6.1021e-02, d2: 0.0000e+00, l1_reg: 3.2845e+02, l2_reg: 5.6764e+01\n",
      "2020/09/08, 22:05:26, Iteration: 7300, Train Loss: 6.8853e+00, c1: 5.4186e-03, c2: 2.9681e-03, d1: 6.0467e-02, d2: 0.0000e+00, l1_reg: 3.2865e+02, l2_reg: 5.6900e+01\n",
      "2020/09/08, 22:05:27, Iteration: 7400, Train Loss: 7.0610e+00, c1: 6.2463e-03, c2: 4.2478e-03, d1: 6.0115e-02, d2: 0.0000e+00, l1_reg: 3.2893e+02, l2_reg: 5.7057e+01\n",
      "2020/09/08, 22:05:28, Iteration: 7500, Train Loss: 7.3102e+00, c1: 8.5159e-03, c2: 4.7674e-03, d1: 5.9819e-02, d2: 0.0000e+00, l1_reg: 3.2914e+02, l2_reg: 5.7188e+01\n",
      "2020/09/08, 22:05:29, Iteration: 7600, Train Loss: 7.0478e+00, c1: 6.2112e-03, c2: 4.9460e-03, d1: 5.9320e-02, d2: 0.0000e+00, l1_reg: 3.2933e+02, l2_reg: 5.7314e+01\n",
      "2020/09/08, 22:05:30, Iteration: 7700, Train Loss: 7.0022e+00, c1: 5.7406e-03, c2: 5.1817e-03, d1: 5.9100e-02, d2: 0.0000e+00, l1_reg: 3.2948e+02, l2_reg: 5.7453e+01\n",
      "2020/09/08, 22:05:31, Iteration: 7800, Train Loss: 6.5386e+00, c1: 3.2156e-03, c2: 3.3899e-03, d1: 5.8781e-02, d2: 0.0000e+00, l1_reg: 3.2974e+02, l2_reg: 5.7589e+01\n",
      "2020/09/08, 22:05:31, Iteration: 7900, Train Loss: 6.6151e+00, c1: 4.4652e-03, c2: 3.3114e-03, d1: 5.8374e-02, d2: 0.0000e+00, l1_reg: 3.2997e+02, l2_reg: 5.7709e+01\n",
      "2020/09/08, 22:05:32, Iteration: 8000, Train Loss: 6.8483e+00, c1: 6.1559e-03, c2: 4.3575e-03, d1: 5.7970e-02, d2: 0.0000e+00, l1_reg: 3.3017e+02, l2_reg: 5.7830e+01\n",
      "2020/09/08, 22:05:33, Iteration: 8100, Train Loss: 6.9691e+00, c1: 5.6976e-03, c2: 5.7039e-03, d1: 5.8289e-02, d2: 0.0000e+00, l1_reg: 3.3035e+02, l2_reg: 5.7940e+01\n",
      "2020/09/08, 22:05:34, Iteration: 8200, Train Loss: 7.1864e+00, c1: 6.1555e-03, c2: 7.8086e-03, d1: 5.7900e-02, d2: 0.0000e+00, l1_reg: 3.3050e+02, l2_reg: 5.8054e+01\n",
      "2020/09/08, 22:05:35, Iteration: 8300, Train Loss: 7.1228e+00, c1: 6.5122e-03, c2: 7.0460e-03, d1: 5.7670e-02, d2: 0.0000e+00, l1_reg: 3.3066e+02, l2_reg: 5.8160e+01\n",
      "2020/09/08, 22:05:36, Iteration: 8400, Train Loss: 6.5635e+00, c1: 5.5512e-03, c2: 3.0306e-03, d1: 5.7054e-02, d2: 0.0000e+00, l1_reg: 3.3080e+02, l2_reg: 5.8248e+01\n",
      "2020/09/08, 22:05:37, Iteration: 8500, Train Loss: 6.3809e+00, c1: 3.8149e-03, c2: 3.0173e-03, d1: 5.6977e-02, d2: 0.0000e+00, l1_reg: 3.3102e+02, l2_reg: 5.8339e+01\n",
      "2020/09/08, 22:05:37, Iteration: 8600, Train Loss: 7.6449e+00, c1: 9.5091e-03, c2: 8.8121e-03, d1: 5.8128e-02, d2: 0.0000e+00, l1_reg: 3.3114e+02, l2_reg: 5.8411e+01\n",
      "2020/09/08, 22:05:38, Iteration: 8700, Train Loss: 6.4081e+00, c1: 2.8155e-03, c2: 4.5939e-03, d1: 5.6672e-02, d2: 0.0000e+00, l1_reg: 3.3128e+02, l2_reg: 5.8494e+01\n",
      "2020/09/08, 22:05:39, Iteration: 8800, Train Loss: 6.8459e+00, c1: 5.3701e-03, c2: 6.0123e-03, d1: 5.7077e-02, d2: 0.0000e+00, l1_reg: 3.3144e+02, l2_reg: 5.8581e+01\n",
      "2020/09/08, 22:05:40, Iteration: 8900, Train Loss: 6.5630e+00, c1: 4.9979e-03, c2: 4.2422e-03, d1: 5.6390e-02, d2: 0.0000e+00, l1_reg: 3.3154e+02, l2_reg: 5.8654e+01\n",
      "2020/09/08, 22:05:41, Iteration: 9000, Train Loss: 6.8267e+00, c1: 7.2437e-03, c2: 4.7013e-03, d1: 5.6322e-02, d2: 0.0000e+00, l1_reg: 3.3163e+02, l2_reg: 5.8715e+01\n",
      "2020/09/08, 22:05:42, Iteration: 9100, Train Loss: 6.6349e+00, c1: 6.6249e-03, c2: 3.4987e-03, d1: 5.6225e-02, d2: 0.0000e+00, l1_reg: 3.3173e+02, l2_reg: 5.8781e+01\n",
      "2020/09/08, 22:05:42, Iteration: 9200, Train Loss: 7.1043e+00, c1: 9.1967e-03, c2: 5.4741e-03, d1: 5.6372e-02, d2: 0.0000e+00, l1_reg: 3.3184e+02, l2_reg: 5.8849e+01\n",
      "2020/09/08, 22:05:43, Iteration: 9300, Train Loss: 7.4328e+00, c1: 1.3844e-02, c2: 4.3244e-03, d1: 5.6159e-02, d2: 0.0000e+00, l1_reg: 3.3183e+02, l2_reg: 5.8869e+01\n",
      "2020/09/08, 22:05:44, Iteration: 9400, Train Loss: 6.7322e+00, c1: 2.8552e-03, c2: 8.3559e-03, d1: 5.6111e-02, d2: 0.0000e+00, l1_reg: 3.3188e+02, l2_reg: 5.8913e+01\n",
      "2020/09/08, 22:05:45, Iteration: 9500, Train Loss: 6.1852e+00, c1: 2.8707e-03, c2: 3.0162e-03, d1: 5.5965e-02, d2: 0.0000e+00, l1_reg: 3.3194e+02, l2_reg: 5.8970e+01\n",
      "2020/09/08, 22:05:46, Iteration: 9600, Train Loss: 6.7745e+00, c1: 8.5381e-03, c2: 3.3496e-03, d1: 5.5857e-02, d2: 0.0000e+00, l1_reg: 3.3205e+02, l2_reg: 5.9037e+01\n",
      "2020/09/08, 22:05:47, Iteration: 9700, Train Loss: 6.7704e+00, c1: 7.3680e-03, c2: 4.6863e-03, d1: 5.5650e-02, d2: 0.0000e+00, l1_reg: 3.3216e+02, l2_reg: 5.9102e+01\n",
      "2020/09/08, 22:05:47, Iteration: 9800, Train Loss: 6.8773e+00, c1: 5.0929e-03, c2: 7.7302e-03, d1: 5.5949e-02, d2: 0.0000e+00, l1_reg: 3.3228e+02, l2_reg: 5.9163e+01\n",
      "2020/09/08, 22:05:48, Iteration: 9900, Train Loss: 6.5576e+00, c1: 5.5225e-03, c2: 4.3909e-03, d1: 5.5662e-02, d2: 0.0000e+00, l1_reg: 3.3233e+02, l2_reg: 5.9207e+01\n",
      "2020/09/08, 22:05:49, Iteration: 10000, Train Loss: 6.3965e+00, c1: 3.6837e-03, c2: 4.7609e-03, d1: 5.5520e-02, d2: 0.0000e+00, l1_reg: 3.3242e+02, l2_reg: 5.9266e+01\n"
     ]
    }
   ],
   "source": [
    "import jax\n",
    "import jax.numpy as jnp\n",
    "\n",
    "import os, sys\n",
    "sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(\"./\")))))\n",
    "\n",
    "from training import Agent\n",
    "from loss import params, loss_fn, evaluate_fn\n",
    "from data import generate_dataset, generate_batch_fn\n",
    "\n",
    "import config\n",
    "config.n_data = {\n",
    "    \"i\": 100,\n",
    "    \"b\": 100,\n",
    "    \"cx\": 501,\n",
    "    \"ct\": 201,\n",
    "    \"dx\": 2000,\n",
    "    \"dt\": 500,\n",
    "}\n",
    "config.batch_size = {\n",
    "    \"dirichlet\": (config.n_data[\"i\"]+2*config.n_data[\"b\"]+config.n_data[\"dx\"]*config.n_data[\"dt\"]) // 100,\n",
    "    \"collocation\": (config.n_data[\"dx\"]*config.n_data[\"dt\"]+config.n_data[\"cx\"]*config.n_data[\"ct\"]) // 100,\n",
    "}\n",
    "config.iterations = 10000\n",
    "config.print_every = 100\n",
    "config.lr = 1e-3\n",
    "config.weights = {\n",
    "\t\"c1\": 1e2,\n",
    "\t\"c2\": 1e2,\n",
    "\t\"d1\": 1e2,\n",
    "\t\"d2\": 1.0,\n",
    "\t\"l1\": 1e-8,\n",
    "\t\"l2\": 1e-8,\n",
    "    \"s\": 1e-8\n",
    "}\n",
    "config.save_every = 1000\n",
    "config.NAME = \"0.7\"\n",
    "\n",
    "datasets = generate_dataset(config.n_data[\"i\"], config.n_data[\"b\"], config.n_data[\"cx\"], config.n_data[\"ct\"], config.n_data[\"dx\"], config.n_data[\"dt\"])\n",
    "batch_fn, evaluate_batch_fn = generate_batch_fn(config.key, config.batch_size, *datasets, config.weights)\n",
    "\n",
    "agent = Agent(params, loss_fn, evaluate_fn, \"models/{}\".format(config.NAME))\n",
    "agent.compile(config.optimizer, config.lr)\n",
    "agent.train(config.iterations, batch_fn, evaluate_batch_fn, config.print_every, config.save_every, config.loss_names, config.log_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020/09/08, 22:06:23, Iteration: 11000, Train Loss: 6.9895e+00, c1: 8.3206e-03, c2: 6.4715e-03, d1: 5.5103e-02, d2: 0.0000e+00, l1_reg: 3.3322e+02, l2_reg: 5.9810e+01\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/lib/python3.8/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
      "  return array(a, dtype, copy=False, order=order)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020/09/08, 22:06:31, Iteration: 12000, Train Loss: 6.4846e+00, c1: 4.4464e-03, c2: 6.7524e-03, d1: 5.3647e-02, d2: 0.0000e+00, l1_reg: 3.3421e+02, l2_reg: 6.0471e+01\n",
      "2020/09/08, 22:06:39, Iteration: 13000, Train Loss: 6.0229e+00, c1: 4.0179e-03, c2: 3.7751e-03, d1: 5.2436e-02, d2: 0.0000e+00, l1_reg: 3.3491e+02, l2_reg: 6.1038e+01\n",
      "2020/09/08, 22:06:48, Iteration: 14000, Train Loss: 6.4121e+00, c1: 4.0957e-03, c2: 7.7217e-03, d1: 5.2304e-02, d2: 0.0000e+00, l1_reg: 3.3541e+02, l2_reg: 6.1592e+01\n",
      "2020/09/08, 22:06:56, Iteration: 15000, Train Loss: 6.1101e+00, c1: 4.9279e-03, c2: 4.9839e-03, d1: 5.1190e-02, d2: 0.0000e+00, l1_reg: 3.3594e+02, l2_reg: 6.2162e+01\n",
      "2020/09/08, 22:07:04, Iteration: 16000, Train Loss: 6.0981e+00, c1: 6.0347e-03, c2: 4.2669e-03, d1: 5.0679e-02, d2: 0.0000e+00, l1_reg: 3.3632e+02, l2_reg: 6.2713e+01\n",
      "2020/09/08, 22:07:12, Iteration: 17000, Train Loss: 5.4059e+00, c1: 2.5509e-03, c2: 2.4394e-03, d1: 4.9069e-02, d2: 0.0000e+00, l1_reg: 3.3658e+02, l2_reg: 6.3234e+01\n",
      "2020/09/08, 22:07:20, Iteration: 18000, Train Loss: 5.6271e+00, c1: 5.8542e-03, c2: 2.7767e-03, d1: 4.7640e-02, d2: 0.0000e+00, l1_reg: 3.3682e+02, l2_reg: 6.3856e+01\n",
      "2020/09/08, 22:07:29, Iteration: 19000, Train Loss: 5.5666e+00, c1: 3.7487e-03, c2: 5.7946e-03, d1: 4.6123e-02, d2: 0.0000e+00, l1_reg: 3.3711e+02, l2_reg: 6.4644e+01\n",
      "2020/09/08, 22:07:37, Iteration: 20000, Train Loss: 5.1628e+00, c1: 2.6312e-03, c2: 4.4276e-03, d1: 4.4569e-02, d2: 0.0000e+00, l1_reg: 3.3766e+02, l2_reg: 6.5532e+01\n",
      "2020/09/08, 22:07:45, Iteration: 21000, Train Loss: 5.1724e+00, c1: 5.5053e-03, c2: 3.8818e-03, d1: 4.2337e-02, d2: 0.0000e+00, l1_reg: 3.3872e+02, l2_reg: 6.6607e+01\n",
      "2020/09/08, 22:07:53, Iteration: 22000, Train Loss: 4.4634e+00, c1: 2.0046e-03, c2: 2.5780e-03, d1: 4.0051e-02, d2: 0.0000e+00, l1_reg: 3.4052e+02, l2_reg: 6.8002e+01\n",
      "2020/09/08, 22:08:02, Iteration: 23000, Train Loss: 4.3058e+00, c1: 3.8714e-03, c2: 2.9294e-03, d1: 3.6257e-02, d2: 0.0000e+00, l1_reg: 3.4376e+02, l2_reg: 7.0144e+01\n",
      "2020/09/08, 22:08:10, Iteration: 24000, Train Loss: 4.4520e+00, c1: 4.5530e-03, c2: 7.2857e-03, d1: 3.2681e-02, d2: 0.0000e+00, l1_reg: 3.4690e+02, l2_reg: 7.2319e+01\n",
      "2020/09/08, 22:08:18, Iteration: 25000, Train Loss: 3.4208e+00, c1: 3.5395e-03, c2: 3.2257e-03, d1: 2.7443e-02, d2: 0.0000e+00, l1_reg: 3.5025e+02, l2_reg: 7.4866e+01\n",
      "2020/09/08, 22:08:26, Iteration: 26000, Train Loss: 3.0700e+00, c1: 3.1111e-03, c2: 2.9294e-03, d1: 2.4659e-02, d2: 0.0000e+00, l1_reg: 3.5142e+02, l2_reg: 7.6405e+01\n",
      "2020/09/08, 22:08:35, Iteration: 27000, Train Loss: 3.3695e+00, c1: 6.2794e-03, c2: 4.1677e-03, d1: 2.3248e-02, d2: 0.0000e+00, l1_reg: 3.5264e+02, l2_reg: 7.7818e+01\n",
      "2020/09/08, 22:08:43, Iteration: 28000, Train Loss: 2.9275e+00, c1: 3.9473e-03, c2: 3.2373e-03, d1: 2.2090e-02, d2: 0.0000e+00, l1_reg: 3.5399e+02, l2_reg: 7.9254e+01\n",
      "2020/09/08, 22:08:51, Iteration: 29000, Train Loss: 2.8572e+00, c1: 3.4571e-03, c2: 4.7499e-03, d1: 2.0365e-02, d2: 0.0000e+00, l1_reg: 3.5572e+02, l2_reg: 8.1172e+01\n",
      "2020/09/08, 22:08:59, Iteration: 30000, Train Loss: 2.4709e+00, c1: 3.1244e-03, c2: 2.2198e-03, d1: 1.9364e-02, d2: 0.0000e+00, l1_reg: 3.5744e+02, l2_reg: 8.3058e+01\n",
      "2020/09/08, 22:09:07, Iteration: 31000, Train Loss: 2.5212e+00, c1: 3.0143e-03, c2: 4.1148e-03, d1: 1.8082e-02, d2: 0.0000e+00, l1_reg: 3.5878e+02, l2_reg: 8.4647e+01\n",
      "2020/09/08, 22:09:15, Iteration: 32000, Train Loss: 2.4327e+00, c1: 2.5446e-03, c2: 4.3012e-03, d1: 1.7481e-02, d2: 0.0000e+00, l1_reg: 3.5930e+02, l2_reg: 8.5736e+01\n",
      "2020/09/08, 22:09:24, Iteration: 33000, Train Loss: 2.2610e+00, c1: 3.3322e-03, c2: 2.4638e-03, d1: 1.6814e-02, d2: 0.0000e+00, l1_reg: 3.5995e+02, l2_reg: 8.6887e+01\n",
      "2020/09/08, 22:09:32, Iteration: 34000, Train Loss: 2.1193e+00, c1: 2.7891e-03, c2: 2.1990e-03, d1: 1.6204e-02, d2: 0.0000e+00, l1_reg: 3.6062e+02, l2_reg: 8.8009e+01\n",
      "2020/09/08, 22:09:40, Iteration: 35000, Train Loss: 2.2131e+00, c1: 2.9934e-03, c2: 3.0457e-03, d1: 1.6092e-02, d2: 0.0000e+00, l1_reg: 3.6157e+02, l2_reg: 8.9236e+01\n",
      "2020/09/08, 22:09:48, Iteration: 36000, Train Loss: 2.0055e+00, c1: 3.0204e-03, c2: 1.9329e-03, d1: 1.5102e-02, d2: 0.0000e+00, l1_reg: 3.6270e+02, l2_reg: 9.0589e+01\n",
      "2020/09/08, 22:09:56, Iteration: 37000, Train Loss: 2.0716e+00, c1: 3.2357e-03, c2: 2.7913e-03, d1: 1.4689e-02, d2: 0.0000e+00, l1_reg: 3.6385e+02, l2_reg: 9.1960e+01\n",
      "2020/09/08, 22:10:04, Iteration: 38000, Train Loss: 2.0389e+00, c1: 3.3534e-03, c2: 2.6517e-03, d1: 1.4383e-02, d2: 0.0000e+00, l1_reg: 3.6502e+02, l2_reg: 9.3356e+01\n",
      "2020/09/08, 22:10:12, Iteration: 39000, Train Loss: 1.8163e+00, c1: 1.8769e-03, c2: 2.3953e-03, d1: 1.3890e-02, d2: 0.0000e+00, l1_reg: 3.6604e+02, l2_reg: 9.4609e+01\n",
      "2020/09/08, 22:10:21, Iteration: 40000, Train Loss: 1.8634e+00, c1: 3.3992e-03, c2: 1.7267e-03, d1: 1.3508e-02, d2: 0.0000e+00, l1_reg: 3.6691e+02, l2_reg: 9.5760e+01\n",
      "2020/09/08, 22:10:29, Iteration: 41000, Train Loss: 1.8865e+00, c1: 2.9373e-03, c2: 2.6768e-03, d1: 1.3251e-02, d2: 0.0000e+00, l1_reg: 3.6780e+02, l2_reg: 9.6913e+01\n",
      "2020/09/08, 22:10:37, Iteration: 42000, Train Loss: 1.7885e+00, c1: 2.4496e-03, c2: 2.6388e-03, d1: 1.2796e-02, d2: 0.0000e+00, l1_reg: 3.6864e+02, l2_reg: 9.8054e+01\n",
      "2020/09/08, 22:10:45, Iteration: 43000, Train Loss: 1.8093e+00, c1: 3.1982e-03, c2: 2.1186e-03, d1: 1.2776e-02, d2: 0.0000e+00, l1_reg: 3.6961e+02, l2_reg: 9.9260e+01\n",
      "2020/09/08, 22:10:53, Iteration: 44000, Train Loss: 1.7868e+00, c1: 3.2377e-03, c2: 2.4403e-03, d1: 1.2190e-02, d2: 0.0000e+00, l1_reg: 3.7061e+02, l2_reg: 1.0045e+02\n",
      "2020/09/08, 22:11:02, Iteration: 45000, Train Loss: 1.7318e+00, c1: 2.0129e-03, c2: 3.1402e-03, d1: 1.2165e-02, d2: 0.0000e+00, l1_reg: 3.7152e+02, l2_reg: 1.0156e+02\n",
      "2020/09/08, 22:11:10, Iteration: 46000, Train Loss: 1.6401e+00, c1: 2.0064e-03, c2: 2.5710e-03, d1: 1.1824e-02, d2: 0.0000e+00, l1_reg: 3.7236e+02, l2_reg: 1.0262e+02\n",
      "2020/09/08, 22:11:18, Iteration: 47000, Train Loss: 1.7308e+00, c1: 2.6103e-03, c2: 3.0307e-03, d1: 1.1667e-02, d2: 0.0000e+00, l1_reg: 3.7321e+02, l2_reg: 1.0371e+02\n",
      "2020/09/08, 22:11:26, Iteration: 48000, Train Loss: 1.5028e+00, c1: 1.9607e-03, c2: 1.8757e-03, d1: 1.1192e-02, d2: 0.0000e+00, l1_reg: 3.7417e+02, l2_reg: 1.0488e+02\n",
      "2020/09/08, 22:11:34, Iteration: 49000, Train Loss: 1.6065e+00, c1: 2.9314e-03, c2: 2.0392e-03, d1: 1.1094e-02, d2: 0.0000e+00, l1_reg: 3.7493e+02, l2_reg: 1.0594e+02\n",
      "2020/09/08, 22:11:42, Iteration: 50000, Train Loss: 1.5049e+00, c1: 2.0717e-03, c2: 2.2382e-03, d1: 1.0739e-02, d2: 0.0000e+00, l1_reg: 3.7564e+02, l2_reg: 1.0696e+02\n",
      "2020/09/08, 22:11:51, Iteration: 51000, Train Loss: 1.6568e+00, c1: 2.3849e-03, c2: 3.0303e-03, d1: 1.1153e-02, d2: 0.0000e+00, l1_reg: 3.7619e+02, l2_reg: 1.0793e+02\n",
      "2020/09/08, 22:11:59, Iteration: 52000, Train Loss: 1.4821e+00, c1: 2.3759e-03, c2: 1.8670e-03, d1: 1.0578e-02, d2: 0.0000e+00, l1_reg: 3.7674e+02, l2_reg: 1.0891e+02\n",
      "2020/09/08, 22:12:07, Iteration: 53000, Train Loss: 1.5668e+00, c1: 2.7593e-03, c2: 2.5369e-03, d1: 1.0372e-02, d2: 0.0000e+00, l1_reg: 3.7733e+02, l2_reg: 1.0989e+02\n",
      "2020/09/08, 22:12:15, Iteration: 54000, Train Loss: 1.4075e+00, c1: 2.1829e-03, c2: 1.6895e-03, d1: 1.0203e-02, d2: 0.0000e+00, l1_reg: 3.7760e+02, l2_reg: 1.1079e+02\n",
      "2020/09/08, 22:12:24, Iteration: 55000, Train Loss: 1.3898e+00, c1: 1.7074e-03, c2: 1.6881e-03, d1: 1.0502e-02, d2: 0.0000e+00, l1_reg: 3.7762e+02, l2_reg: 1.1149e+02\n",
      "2020/09/08, 22:12:32, Iteration: 56000, Train Loss: 1.5174e+00, c1: 3.2044e-03, c2: 2.3328e-03, d1: 9.6372e-03, d2: 0.0000e+00, l1_reg: 3.7765e+02, l2_reg: 1.1210e+02\n",
      "2020/09/08, 22:12:40, Iteration: 57000, Train Loss: 1.3791e+00, c1: 1.8251e-03, c2: 2.3109e-03, d1: 9.6544e-03, d2: 0.0000e+00, l1_reg: 3.7741e+02, l2_reg: 1.1259e+02\n",
      "2020/09/08, 22:12:48, Iteration: 58000, Train Loss: 1.2720e+00, c1: 1.6074e-03, c2: 1.4804e-03, d1: 9.6319e-03, d2: 0.0000e+00, l1_reg: 3.7723e+02, l2_reg: 1.1309e+02\n",
      "2020/09/08, 22:12:57, Iteration: 59000, Train Loss: 1.3573e+00, c1: 1.9095e-03, c2: 1.7631e-03, d1: 9.9009e-03, d2: 0.0000e+00, l1_reg: 3.7709e+02, l2_reg: 1.1356e+02\n",
      "2020/09/08, 22:13:05, Iteration: 60000, Train Loss: 1.2722e+00, c1: 1.4420e-03, c2: 1.4799e-03, d1: 9.7997e-03, d2: 0.0000e+00, l1_reg: 3.7708e+02, l2_reg: 1.1413e+02\n",
      "2020/09/08, 22:13:13, Iteration: 61000, Train Loss: 1.2833e+00, c1: 1.1003e-03, c2: 1.8184e-03, d1: 9.9139e-03, d2: 0.0000e+00, l1_reg: 3.7699e+02, l2_reg: 1.1463e+02\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2020/09/08, 22:13:21, Iteration: 62000, Train Loss: 1.5650e+00, c1: 3.1804e-03, c2: 2.6050e-03, d1: 9.8648e-03, d2: 0.0000e+00, l1_reg: 3.7696e+02, l2_reg: 1.1513e+02\n",
      "2020/09/08, 22:13:29, Iteration: 63000, Train Loss: 1.4292e+00, c1: 2.2466e-03, c2: 2.5435e-03, d1: 9.5018e-03, d2: 0.0000e+00, l1_reg: 3.7691e+02, l2_reg: 1.1567e+02\n",
      "2020/09/08, 22:13:37, Iteration: 64000, Train Loss: 1.4455e+00, c1: 2.8037e-03, c2: 2.1731e-03, d1: 9.4784e-03, d2: 0.0000e+00, l1_reg: 3.7714e+02, l2_reg: 1.1628e+02\n",
      "2020/09/08, 22:13:46, Iteration: 65000, Train Loss: 1.4120e+00, c1: 2.4177e-03, c2: 2.1508e-03, d1: 9.5515e-03, d2: 0.0000e+00, l1_reg: 3.7724e+02, l2_reg: 1.1685e+02\n",
      "2020/09/08, 22:13:54, Iteration: 66000, Train Loss: 1.4555e+00, c1: 2.7197e-03, c2: 2.7378e-03, d1: 9.0974e-03, d2: 0.0000e+00, l1_reg: 3.7750e+02, l2_reg: 1.1746e+02\n",
      "2020/09/08, 22:14:02, Iteration: 67000, Train Loss: 1.3927e+00, c1: 2.3766e-03, c2: 2.1760e-03, d1: 9.3746e-03, d2: 0.0000e+00, l1_reg: 3.7765e+02, l2_reg: 1.1806e+02\n",
      "2020/09/08, 22:14:10, Iteration: 68000, Train Loss: 1.2389e+00, c1: 1.4858e-03, c2: 1.9326e-03, d1: 8.9708e-03, d2: 0.0000e+00, l1_reg: 3.7785e+02, l2_reg: 1.1865e+02\n",
      "2020/09/08, 22:14:18, Iteration: 69000, Train Loss: 1.3939e+00, c1: 2.9915e-03, c2: 1.9957e-03, d1: 8.9518e-03, d2: 0.0000e+00, l1_reg: 3.7811e+02, l2_reg: 1.1927e+02\n",
      "2020/09/08, 22:14:26, Iteration: 70000, Train Loss: 1.2106e+00, c1: 1.0871e-03, c2: 1.5968e-03, d1: 9.4224e-03, d2: 0.0000e+00, l1_reg: 3.7818e+02, l2_reg: 1.1983e+02\n",
      "2020/09/08, 22:14:35, Iteration: 71000, Train Loss: 1.3768e+00, c1: 2.4345e-03, c2: 1.5866e-03, d1: 9.7471e-03, d2: 0.0000e+00, l1_reg: 3.7836e+02, l2_reg: 1.2042e+02\n",
      "2020/09/08, 22:14:43, Iteration: 72000, Train Loss: 1.1827e+00, c1: 1.7597e-03, c2: 1.0198e-03, d1: 9.0472e-03, d2: 0.0000e+00, l1_reg: 3.7835e+02, l2_reg: 1.2096e+02\n",
      "2020/09/08, 22:14:51, Iteration: 73000, Train Loss: 1.3217e+00, c1: 2.0532e-03, c2: 2.0622e-03, d1: 9.1014e-03, d2: 0.0000e+00, l1_reg: 3.7830e+02, l2_reg: 1.2145e+02\n",
      "2020/09/08, 22:14:59, Iteration: 74000, Train Loss: 1.2657e+00, c1: 1.7676e-03, c2: 1.6207e-03, d1: 9.2692e-03, d2: 0.0000e+00, l1_reg: 3.7811e+02, l2_reg: 1.2194e+02\n",
      "2020/09/08, 22:15:08, Iteration: 75000, Train Loss: 1.2383e+00, c1: 1.4396e-03, c2: 1.8500e-03, d1: 9.0934e-03, d2: 0.0000e+00, l1_reg: 3.7807e+02, l2_reg: 1.2247e+02\n",
      "2020/09/08, 22:15:16, Iteration: 76000, Train Loss: 1.3316e+00, c1: 1.9021e-03, c2: 2.4287e-03, d1: 8.9852e-03, d2: 0.0000e+00, l1_reg: 3.7790e+02, l2_reg: 1.2292e+02\n",
      "2020/09/08, 22:15:24, Iteration: 77000, Train Loss: 1.2532e+00, c1: 1.4655e-03, c2: 1.9222e-03, d1: 9.1440e-03, d2: 0.0000e+00, l1_reg: 3.7772e+02, l2_reg: 1.2340e+02\n",
      "2020/09/08, 22:15:33, Iteration: 78000, Train Loss: 1.2866e+00, c1: 2.2155e-03, c2: 1.6234e-03, d1: 9.0275e-03, d2: 0.0000e+00, l1_reg: 3.7736e+02, l2_reg: 1.2385e+02\n",
      "2020/09/08, 22:15:41, Iteration: 79000, Train Loss: 1.2206e+00, c1: 1.5737e-03, c2: 1.7911e-03, d1: 8.8413e-03, d2: 0.0000e+00, l1_reg: 3.7704e+02, l2_reg: 1.2428e+02\n",
      "2020/09/08, 22:15:49, Iteration: 80000, Train Loss: 1.2237e+00, c1: 1.7097e-03, c2: 1.5181e-03, d1: 9.0095e-03, d2: 0.0000e+00, l1_reg: 3.7689e+02, l2_reg: 1.2472e+02\n",
      "2020/09/08, 22:15:57, Iteration: 81000, Train Loss: 1.2678e+00, c1: 1.9349e-03, c2: 2.0247e-03, d1: 8.7186e-03, d2: 0.0000e+00, l1_reg: 3.7663e+02, l2_reg: 1.2517e+02\n",
      "2020/09/08, 22:16:05, Iteration: 82000, Train Loss: 1.1496e+00, c1: 1.4391e-03, c2: 1.3899e-03, d1: 8.6672e-03, d2: 0.0000e+00, l1_reg: 3.7648e+02, l2_reg: 1.2568e+02\n",
      "2020/09/08, 22:16:14, Iteration: 83000, Train Loss: 1.1715e+00, c1: 1.8509e-03, c2: 1.2376e-03, d1: 8.6267e-03, d2: 0.0000e+00, l1_reg: 3.7624e+02, l2_reg: 1.2611e+02\n",
      "2020/09/08, 22:16:22, Iteration: 84000, Train Loss: 1.1665e+00, c1: 1.3001e-03, c2: 1.4963e-03, d1: 8.8686e-03, d2: 0.0000e+00, l1_reg: 3.7606e+02, l2_reg: 1.2663e+02\n",
      "2020/09/08, 22:16:30, Iteration: 85000, Train Loss: 1.1708e+00, c1: 1.2355e-03, c2: 1.6786e-03, d1: 8.7939e-03, d2: 0.0000e+00, l1_reg: 3.7598e+02, l2_reg: 1.2717e+02\n",
      "2020/09/08, 22:16:38, Iteration: 86000, Train Loss: 1.1776e+00, c1: 1.8754e-03, c2: 1.3230e-03, d1: 8.5778e-03, d2: 0.0000e+00, l1_reg: 3.7578e+02, l2_reg: 1.2762e+02\n",
      "2020/09/08, 22:16:46, Iteration: 87000, Train Loss: 1.1419e+00, c1: 1.2969e-03, c2: 1.4920e-03, d1: 8.6301e-03, d2: 0.0000e+00, l1_reg: 3.7563e+02, l2_reg: 1.2812e+02\n",
      "2020/09/08, 22:16:54, Iteration: 88000, Train Loss: 1.1926e+00, c1: 1.5283e-03, c2: 1.9302e-03, d1: 8.4677e-03, d2: 0.0000e+00, l1_reg: 3.7535e+02, l2_reg: 1.2854e+02\n",
      "2020/09/08, 22:17:01, Iteration: 89000, Train Loss: 1.1979e+00, c1: 1.6437e-03, c2: 1.3115e-03, d1: 9.0243e-03, d2: 0.0000e+00, l1_reg: 3.7506e+02, l2_reg: 1.2897e+02\n",
      "2020/09/08, 22:17:09, Iteration: 90000, Train Loss: 1.1379e+00, c1: 1.3301e-03, c2: 1.4344e-03, d1: 8.6141e-03, d2: 0.0000e+00, l1_reg: 3.7480e+02, l2_reg: 1.2939e+02\n",
      "2020/09/08, 22:17:16, Iteration: 91000, Train Loss: 1.2253e+00, c1: 1.7257e-03, c2: 1.8949e-03, d1: 8.6321e-03, d2: 0.0000e+00, l1_reg: 3.7441e+02, l2_reg: 1.2980e+02\n",
      "2020/09/08, 22:17:24, Iteration: 92000, Train Loss: 1.2099e+00, c1: 1.5460e-03, c2: 1.8066e-03, d1: 8.7467e-03, d2: 0.0000e+00, l1_reg: 3.7399e+02, l2_reg: 1.3012e+02\n",
      "2020/09/08, 22:17:31, Iteration: 93000, Train Loss: 1.2115e+00, c1: 1.5820e-03, c2: 1.7994e-03, d1: 8.7336e-03, d2: 0.0000e+00, l1_reg: 3.7359e+02, l2_reg: 1.3044e+02\n",
      "2020/09/08, 22:17:38, Iteration: 94000, Train Loss: 1.1304e+00, c1: 1.6478e-03, c2: 1.2421e-03, d1: 8.4145e-03, d2: 0.0000e+00, l1_reg: 3.7322e+02, l2_reg: 1.3080e+02\n",
      "2020/09/08, 22:17:46, Iteration: 95000, Train Loss: 1.0640e+00, c1: 9.3973e-04, c2: 1.3325e-03, d1: 8.3682e-03, d2: 0.0000e+00, l1_reg: 3.7292e+02, l2_reg: 1.3115e+02\n",
      "2020/09/08, 22:17:53, Iteration: 96000, Train Loss: 1.1498e+00, c1: 1.6008e-03, c2: 1.3458e-03, d1: 8.5513e-03, d2: 0.0000e+00, l1_reg: 3.7266e+02, l2_reg: 1.3149e+02\n",
      "2020/09/08, 22:18:00, Iteration: 97000, Train Loss: 1.3213e+00, c1: 3.0328e-03, c2: 1.6133e-03, d1: 8.5664e-03, d2: 0.0000e+00, l1_reg: 3.7254e+02, l2_reg: 1.3184e+02\n",
      "2020/09/08, 22:18:08, Iteration: 98000, Train Loss: 1.1300e+00, c1: 1.4283e-03, c2: 1.3673e-03, d1: 8.5044e-03, d2: 0.0000e+00, l1_reg: 3.7244e+02, l2_reg: 1.3223e+02\n",
      "2020/09/08, 22:18:15, Iteration: 99000, Train Loss: 1.1112e+00, c1: 1.2849e-03, c2: 1.4645e-03, d1: 8.3628e-03, d2: 0.0000e+00, l1_reg: 3.7236e+02, l2_reg: 1.3263e+02\n",
      "2020/09/08, 22:18:23, Iteration: 100000, Train Loss: 1.1287e+00, c1: 1.1387e-03, c2: 1.8233e-03, d1: 8.3248e-03, d2: 0.0000e+00, l1_reg: 3.7209e+02, l2_reg: 1.3293e+02\n",
      "2020/09/08, 22:18:30, Iteration: 101000, Train Loss: 1.3146e+00, c1: 2.2308e-03, c2: 1.5558e-03, d1: 9.3594e-03, d2: 0.0000e+00, l1_reg: 3.7213e+02, l2_reg: 1.3333e+02\n",
      "2020/09/08, 22:18:38, Iteration: 102000, Train Loss: 1.1323e+00, c1: 1.6106e-03, c2: 1.0895e-03, d1: 8.6231e-03, d2: 0.0000e+00, l1_reg: 3.7194e+02, l2_reg: 1.3365e+02\n",
      "2020/09/08, 22:18:45, Iteration: 103000, Train Loss: 1.1013e+00, c1: 1.1349e-03, c2: 1.1651e-03, d1: 8.7126e-03, d2: 0.0000e+00, l1_reg: 3.7186e+02, l2_reg: 1.3399e+02\n",
      "2020/09/08, 22:18:52, Iteration: 104000, Train Loss: 1.1671e+00, c1: 9.9139e-04, c2: 2.2811e-03, d1: 8.3980e-03, d2: 0.0000e+00, l1_reg: 3.7175e+02, l2_reg: 1.3432e+02\n",
      "2020/09/08, 22:19:00, Iteration: 105000, Train Loss: 1.1280e+00, c1: 1.4180e-03, c2: 1.2263e-03, d1: 8.6357e-03, d2: 0.0000e+00, l1_reg: 3.7164e+02, l2_reg: 1.3463e+02\n",
      "2020/09/08, 22:19:07, Iteration: 106000, Train Loss: 1.2055e+00, c1: 1.3339e-03, c2: 1.6675e-03, d1: 9.0534e-03, d2: 0.0000e+00, l1_reg: 3.7163e+02, l2_reg: 1.3491e+02\n",
      "2020/09/08, 22:19:15, Iteration: 107000, Train Loss: 1.1137e+00, c1: 1.0618e-03, c2: 1.7497e-03, d1: 8.3259e-03, d2: 0.0000e+00, l1_reg: 3.7168e+02, l2_reg: 1.3523e+02\n",
      "2020/09/08, 22:19:22, Iteration: 108000, Train Loss: 1.1565e+00, c1: 1.3047e-03, c2: 1.7867e-03, d1: 8.4739e-03, d2: 0.0000e+00, l1_reg: 3.7156e+02, l2_reg: 1.3550e+02\n",
      "2020/09/08, 22:19:30, Iteration: 109000, Train Loss: 1.1905e+00, c1: 1.3765e-03, c2: 1.9674e-03, d1: 8.5610e-03, d2: 0.0000e+00, l1_reg: 3.7150e+02, l2_reg: 1.3579e+02\n",
      "2020/09/08, 22:19:37, Iteration: 110000, Train Loss: 1.1637e+00, c1: 1.8901e-03, c2: 1.0404e-03, d1: 8.7068e-03, d2: 0.0000e+00, l1_reg: 3.7147e+02, l2_reg: 1.3603e+02\n"
     ]
    }
   ],
   "source": [
    "config.iterations = 100000\n",
    "config.print_every = 1000\n",
    "agent.train(config.iterations, batch_fn, evaluate_batch_fn, config.print_every, config.save_every, config.loss_names, config.log_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/javascript": [
       "/* Put everything inside the global mpl namespace */\n",
       "/* global mpl */\n",
       "window.mpl = {};\n",
       "\n",
       "mpl.get_websocket_type = function () {\n",
       "    if (typeof WebSocket !== 'undefined') {\n",
       "        return WebSocket;\n",
       "    } else if (typeof MozWebSocket !== 'undefined') {\n",
       "        return MozWebSocket;\n",
       "    } else {\n",
       "        alert(\n",
       "            'Your browser does not have WebSocket support. ' +\n",
       "                'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
       "                'Firefox 4 and 5 are also supported but you ' +\n",
       "                'have to enable WebSockets in about:config.'\n",
       "        );\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n",
       "    this.id = figure_id;\n",
       "\n",
       "    this.ws = websocket;\n",
       "\n",
       "    this.supports_binary = this.ws.binaryType !== undefined;\n",
       "\n",
       "    if (!this.supports_binary) {\n",
       "        var warnings = document.getElementById('mpl-warnings');\n",
       "        if (warnings) {\n",
       "            warnings.style.display = 'block';\n",
       "            warnings.textContent =\n",
       "                'This browser does not support binary websocket messages. ' +\n",
       "                'Performance may be slow.';\n",
       "        }\n",
       "    }\n",
       "\n",
       "    this.imageObj = new Image();\n",
       "\n",
       "    this.context = undefined;\n",
       "    this.message = undefined;\n",
       "    this.canvas = undefined;\n",
       "    this.rubberband_canvas = undefined;\n",
       "    this.rubberband_context = undefined;\n",
       "    this.format_dropdown = undefined;\n",
       "\n",
       "    this.image_mode = 'full';\n",
       "\n",
       "    this.root = document.createElement('div');\n",
       "    this.root.setAttribute('style', 'display: inline-block');\n",
       "    this._root_extra_style(this.root);\n",
       "\n",
       "    parent_element.appendChild(this.root);\n",
       "\n",
       "    this._init_header(this);\n",
       "    this._init_canvas(this);\n",
       "    this._init_toolbar(this);\n",
       "\n",
       "    var fig = this;\n",
       "\n",
       "    this.waiting = false;\n",
       "\n",
       "    this.ws.onopen = function () {\n",
       "        fig.send_message('supports_binary', { value: fig.supports_binary });\n",
       "        fig.send_message('send_image_mode', {});\n",
       "        if (mpl.ratio !== 1) {\n",
       "            fig.send_message('set_dpi_ratio', { dpi_ratio: mpl.ratio });\n",
       "        }\n",
       "        fig.send_message('refresh', {});\n",
       "    };\n",
       "\n",
       "    this.imageObj.onload = function () {\n",
       "        if (fig.image_mode === 'full') {\n",
       "            // Full images could contain transparency (where diff images\n",
       "            // almost always do), so we need to clear the canvas so that\n",
       "            // there is no ghosting.\n",
       "            fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
       "        }\n",
       "        fig.context.drawImage(fig.imageObj, 0, 0);\n",
       "    };\n",
       "\n",
       "    this.imageObj.onunload = function () {\n",
       "        fig.ws.close();\n",
       "    };\n",
       "\n",
       "    this.ws.onmessage = this._make_on_message_function(this);\n",
       "\n",
       "    this.ondownload = ondownload;\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._init_header = function () {\n",
       "    var titlebar = document.createElement('div');\n",
       "    titlebar.classList =\n",
       "        'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n",
       "    var titletext = document.createElement('div');\n",
       "    titletext.classList = 'ui-dialog-title';\n",
       "    titletext.setAttribute(\n",
       "        'style',\n",
       "        'width: 100%; text-align: center; padding: 3px;'\n",
       "    );\n",
       "    titlebar.appendChild(titletext);\n",
       "    this.root.appendChild(titlebar);\n",
       "    this.header = titletext;\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n",
       "\n",
       "mpl.figure.prototype._init_canvas = function () {\n",
       "    var fig = this;\n",
       "\n",
       "    var canvas_div = (this.canvas_div = document.createElement('div'));\n",
       "    canvas_div.setAttribute(\n",
       "        'style',\n",
       "        'border: 1px solid #ddd;' +\n",
       "            'box-sizing: content-box;' +\n",
       "            'clear: both;' +\n",
       "            'min-height: 1px;' +\n",
       "            'min-width: 1px;' +\n",
       "            'outline: 0;' +\n",
       "            'overflow: hidden;' +\n",
       "            'position: relative;' +\n",
       "            'resize: both;'\n",
       "    );\n",
       "\n",
       "    function on_keyboard_event_closure(name) {\n",
       "        return function (event) {\n",
       "            return fig.key_event(event, name);\n",
       "        };\n",
       "    }\n",
       "\n",
       "    canvas_div.addEventListener(\n",
       "        'keydown',\n",
       "        on_keyboard_event_closure('key_press')\n",
       "    );\n",
       "    canvas_div.addEventListener(\n",
       "        'keyup',\n",
       "        on_keyboard_event_closure('key_release')\n",
       "    );\n",
       "\n",
       "    this._canvas_extra_style(canvas_div);\n",
       "    this.root.appendChild(canvas_div);\n",
       "\n",
       "    var canvas = (this.canvas = document.createElement('canvas'));\n",
       "    canvas.classList.add('mpl-canvas');\n",
       "    canvas.setAttribute('style', 'box-sizing: content-box;');\n",
       "\n",
       "    this.context = canvas.getContext('2d');\n",
       "\n",
       "    var backingStore =\n",
       "        this.context.backingStorePixelRatio ||\n",
       "        this.context.webkitBackingStorePixelRatio ||\n",
       "        this.context.mozBackingStorePixelRatio ||\n",
       "        this.context.msBackingStorePixelRatio ||\n",
       "        this.context.oBackingStorePixelRatio ||\n",
       "        this.context.backingStorePixelRatio ||\n",
       "        1;\n",
       "\n",
       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
       "\n",
       "    var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n",
       "        'canvas'\n",
       "    ));\n",
       "    rubberband_canvas.setAttribute(\n",
       "        'style',\n",
       "        'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;'\n",
       "    );\n",
       "\n",
       "    var resizeObserver = new ResizeObserver(function (entries) {\n",
       "        var nentries = entries.length;\n",
       "        for (var i = 0; i < nentries; i++) {\n",
       "            var entry = entries[i];\n",
       "            var width, height;\n",
       "            if (entry.contentBoxSize) {\n",
       "                width = entry.contentBoxSize.inlineSize;\n",
       "                height = entry.contentBoxSize.blockSize;\n",
       "            } else {\n",
       "                width = entry.contentRect.width;\n",
       "                height = entry.contentRect.height;\n",
       "            }\n",
       "\n",
       "            // Keep the size of the canvas and rubber band canvas in sync with\n",
       "            // the canvas container.\n",
       "            canvas.setAttribute('width', width * mpl.ratio);\n",
       "            canvas.setAttribute('height', height * mpl.ratio);\n",
       "            canvas.setAttribute(\n",
       "                'style',\n",
       "                'width: ' + width + 'px; height: ' + height + 'px;'\n",
       "            );\n",
       "\n",
       "            rubberband_canvas.setAttribute('width', width);\n",
       "            rubberband_canvas.setAttribute('height', height);\n",
       "\n",
       "            // And update the size in Python. We ignore the initial 0/0 size\n",
       "            // that occurs as the element is placed into the DOM, which should\n",
       "            // otherwise not happen due to the minimum size styling.\n",
       "            if (width != 0 && height != 0) {\n",
       "                fig.request_resize(width, height);\n",
       "            }\n",
       "        }\n",
       "    });\n",
       "    resizeObserver.observe(canvas_div);\n",
       "\n",
       "    function on_mouse_event_closure(name) {\n",
       "        return function (event) {\n",
       "            return fig.mouse_event(event, name);\n",
       "        };\n",
       "    }\n",
       "\n",
       "    rubberband_canvas.addEventListener(\n",
       "        'mousedown',\n",
       "        on_mouse_event_closure('button_press')\n",
       "    );\n",
       "    rubberband_canvas.addEventListener(\n",
       "        'mouseup',\n",
       "        on_mouse_event_closure('button_release')\n",
       "    );\n",
       "    // Throttle sequential mouse events to 1 every 20ms.\n",
       "    rubberband_canvas.addEventListener(\n",
       "        'mousemove',\n",
       "        on_mouse_event_closure('motion_notify')\n",
       "    );\n",
       "\n",
       "    rubberband_canvas.addEventListener(\n",
       "        'mouseenter',\n",
       "        on_mouse_event_closure('figure_enter')\n",
       "    );\n",
       "    rubberband_canvas.addEventListener(\n",
       "        'mouseleave',\n",
       "        on_mouse_event_closure('figure_leave')\n",
       "    );\n",
       "\n",
       "    canvas_div.addEventListener('wheel', function (event) {\n",
       "        if (event.deltaY < 0) {\n",
       "            event.step = 1;\n",
       "        } else {\n",
       "            event.step = -1;\n",
       "        }\n",
       "        on_mouse_event_closure('scroll')(event);\n",
       "    });\n",
       "\n",
       "    canvas_div.appendChild(canvas);\n",
       "    canvas_div.appendChild(rubberband_canvas);\n",
       "\n",
       "    this.rubberband_context = rubberband_canvas.getContext('2d');\n",
       "    this.rubberband_context.strokeStyle = '#000000';\n",
       "\n",
       "    this._resize_canvas = function (width, height, forward) {\n",
       "        if (forward) {\n",
       "            canvas_div.style.width = width + 'px';\n",
       "            canvas_div.style.height = height + 'px';\n",
       "        }\n",
       "    };\n",
       "\n",
       "    // Disable right mouse context menu.\n",
       "    this.rubberband_canvas.addEventListener('contextmenu', function (_e) {\n",
       "        return false;\n",
       "    });\n",
       "\n",
       "    function set_focus() {\n",
       "        canvas.focus();\n",
       "        canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    window.setTimeout(set_focus, 100);\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function () {\n",
       "    var fig = this;\n",
       "\n",
       "    var toolbar = document.createElement('div');\n",
       "    toolbar.classList = 'mpl-toolbar';\n",
       "    this.root.appendChild(toolbar);\n",
       "\n",
       "    function on_click_closure(name) {\n",
       "        return function (_event) {\n",
       "            return fig.toolbar_button_onclick(name);\n",
       "        };\n",
       "    }\n",
       "\n",
       "    function on_mouseover_closure(tooltip) {\n",
       "        return function (event) {\n",
       "            if (!event.currentTarget.disabled) {\n",
       "                return fig.toolbar_button_onmouseover(tooltip);\n",
       "            }\n",
       "        };\n",
       "    }\n",
       "\n",
       "    fig.buttons = {};\n",
       "    var buttonGroup = document.createElement('div');\n",
       "    buttonGroup.classList = 'mpl-button-group';\n",
       "    for (var toolbar_ind in mpl.toolbar_items) {\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) {\n",
       "            /* Instead of a spacer, we start a new button group. */\n",
       "            if (buttonGroup.hasChildNodes()) {\n",
       "                toolbar.appendChild(buttonGroup);\n",
       "            }\n",
       "            buttonGroup = document.createElement('div');\n",
       "            buttonGroup.classList = 'mpl-button-group';\n",
       "            continue;\n",
       "        }\n",
       "\n",
       "        var button = (fig.buttons[name] = document.createElement('button'));\n",
       "        button.classList = 'mpl-widget';\n",
       "        button.setAttribute('role', 'button');\n",
       "        button.setAttribute('aria-disabled', 'false');\n",
       "        button.addEventListener('click', on_click_closure(method_name));\n",
       "        button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n",
       "\n",
       "        var icon_img = document.createElement('img');\n",
       "        icon_img.src = '_images/' + image + '.png';\n",
       "        icon_img.srcset = '_images/' + image + '_large.png 2x';\n",
       "        icon_img.alt = tooltip;\n",
       "        button.appendChild(icon_img);\n",
       "\n",
       "        buttonGroup.appendChild(button);\n",
       "    }\n",
       "\n",
       "    if (buttonGroup.hasChildNodes()) {\n",
       "        toolbar.appendChild(buttonGroup);\n",
       "    }\n",
       "\n",
       "    var fmt_picker = document.createElement('select');\n",
       "    fmt_picker.classList = 'mpl-widget';\n",
       "    toolbar.appendChild(fmt_picker);\n",
       "    this.format_dropdown = fmt_picker;\n",
       "\n",
       "    for (var ind in mpl.extensions) {\n",
       "        var fmt = mpl.extensions[ind];\n",
       "        var option = document.createElement('option');\n",
       "        option.selected = fmt === mpl.default_extension;\n",
       "        option.innerHTML = fmt;\n",
       "        fmt_picker.appendChild(option);\n",
       "    }\n",
       "\n",
       "    var status_bar = document.createElement('span');\n",
       "    status_bar.classList = 'mpl-message';\n",
       "    toolbar.appendChild(status_bar);\n",
       "    this.message = status_bar;\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n",
       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
       "    // which will in turn request a refresh of the image.\n",
       "    this.send_message('resize', { width: x_pixels, height: y_pixels });\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.send_message = function (type, properties) {\n",
       "    properties['type'] = type;\n",
       "    properties['figure_id'] = this.id;\n",
       "    this.ws.send(JSON.stringify(properties));\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.send_draw_message = function () {\n",
       "    if (!this.waiting) {\n",
       "        this.waiting = true;\n",
       "        this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_save = function (fig, _msg) {\n",
       "    var format_dropdown = fig.format_dropdown;\n",
       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
       "    fig.ondownload(fig, format);\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_resize = function (fig, msg) {\n",
       "    var size = msg['size'];\n",
       "    if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n",
       "        fig._resize_canvas(size[0], size[1], msg['forward']);\n",
       "        fig.send_message('refresh', {});\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_rubberband = function (fig, msg) {\n",
       "    var x0 = msg['x0'] / mpl.ratio;\n",
       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
       "    var x1 = msg['x1'] / mpl.ratio;\n",
       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
       "    x0 = Math.floor(x0) + 0.5;\n",
       "    y0 = Math.floor(y0) + 0.5;\n",
       "    x1 = Math.floor(x1) + 0.5;\n",
       "    y1 = Math.floor(y1) + 0.5;\n",
       "    var min_x = Math.min(x0, x1);\n",
       "    var min_y = Math.min(y0, y1);\n",
       "    var width = Math.abs(x1 - x0);\n",
       "    var height = Math.abs(y1 - y0);\n",
       "\n",
       "    fig.rubberband_context.clearRect(\n",
       "        0,\n",
       "        0,\n",
       "        fig.canvas.width / mpl.ratio,\n",
       "        fig.canvas.height / mpl.ratio\n",
       "    );\n",
       "\n",
       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_figure_label = function (fig, msg) {\n",
       "    // Updates the figure title.\n",
       "    fig.header.textContent = msg['label'];\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_cursor = function (fig, msg) {\n",
       "    var cursor = msg['cursor'];\n",
       "    switch (cursor) {\n",
       "        case 0:\n",
       "            cursor = 'pointer';\n",
       "            break;\n",
       "        case 1:\n",
       "            cursor = 'default';\n",
       "            break;\n",
       "        case 2:\n",
       "            cursor = 'crosshair';\n",
       "            break;\n",
       "        case 3:\n",
       "            cursor = 'move';\n",
       "            break;\n",
       "    }\n",
       "    fig.rubberband_canvas.style.cursor = cursor;\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_message = function (fig, msg) {\n",
       "    fig.message.textContent = msg['message'];\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_draw = function (fig, _msg) {\n",
       "    // Request the server to send over a new figure.\n",
       "    fig.send_draw_message();\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_image_mode = function (fig, msg) {\n",
       "    fig.image_mode = msg['mode'];\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n",
       "    for (var key in msg) {\n",
       "        if (!(key in fig.buttons)) {\n",
       "            continue;\n",
       "        }\n",
       "        fig.buttons[key].disabled = !msg[key];\n",
       "        fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n",
       "    if (msg['mode'] === 'PAN') {\n",
       "        fig.buttons['Pan'].classList.add('active');\n",
       "        fig.buttons['Zoom'].classList.remove('active');\n",
       "    } else if (msg['mode'] === 'ZOOM') {\n",
       "        fig.buttons['Pan'].classList.remove('active');\n",
       "        fig.buttons['Zoom'].classList.add('active');\n",
       "    } else {\n",
       "        fig.buttons['Pan'].classList.remove('active');\n",
       "        fig.buttons['Zoom'].classList.remove('active');\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function () {\n",
       "    // Called whenever the canvas gets updated.\n",
       "    this.send_message('ack', {});\n",
       "};\n",
       "\n",
       "// A function to construct a web socket function for onmessage handling.\n",
       "// Called in the figure constructor.\n",
       "mpl.figure.prototype._make_on_message_function = function (fig) {\n",
       "    return function socket_on_message(evt) {\n",
       "        if (evt.data instanceof Blob) {\n",
       "            /* FIXME: We get \"Resource interpreted as Image but\n",
       "             * transferred with MIME type text/plain:\" errors on\n",
       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
       "             * to be part of the websocket stream */\n",
       "            evt.data.type = 'image/png';\n",
       "\n",
       "            /* Free the memory for the previous frames */\n",
       "            if (fig.imageObj.src) {\n",
       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
       "                    fig.imageObj.src\n",
       "                );\n",
       "            }\n",
       "\n",
       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
       "                evt.data\n",
       "            );\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        } else if (\n",
       "            typeof evt.data === 'string' &&\n",
       "            evt.data.slice(0, 21) === 'data:image/png;base64'\n",
       "        ) {\n",
       "            fig.imageObj.src = evt.data;\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        var msg = JSON.parse(evt.data);\n",
       "        var msg_type = msg['type'];\n",
       "\n",
       "        // Call the  \"handle_{type}\" callback, which takes\n",
       "        // the figure and JSON message as its only arguments.\n",
       "        try {\n",
       "            var callback = fig['handle_' + msg_type];\n",
       "        } catch (e) {\n",
       "            console.log(\n",
       "                \"No handler for the '\" + msg_type + \"' message type: \",\n",
       "                msg\n",
       "            );\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        if (callback) {\n",
       "            try {\n",
       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
       "                callback(fig, msg);\n",
       "            } catch (e) {\n",
       "                console.log(\n",
       "                    \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n",
       "                    e,\n",
       "                    e.stack,\n",
       "                    msg\n",
       "                );\n",
       "            }\n",
       "        }\n",
       "    };\n",
       "};\n",
       "\n",
       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
       "mpl.findpos = function (e) {\n",
       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
       "    var targ;\n",
       "    if (!e) {\n",
       "        e = window.event;\n",
       "    }\n",
       "    if (e.target) {\n",
       "        targ = e.target;\n",
       "    } else if (e.srcElement) {\n",
       "        targ = e.srcElement;\n",
       "    }\n",
       "    if (targ.nodeType === 3) {\n",
       "        // defeat Safari bug\n",
       "        targ = targ.parentNode;\n",
       "    }\n",
       "\n",
       "    // pageX,Y are the mouse positions relative to the document\n",
       "    var boundingRect = targ.getBoundingClientRect();\n",
       "    var x = e.pageX - (boundingRect.left + document.body.scrollLeft);\n",
       "    var y = e.pageY - (boundingRect.top + document.body.scrollTop);\n",
       "\n",
       "    return { x: x, y: y };\n",
       "};\n",
       "\n",
       "/*\n",
       " * return a copy of an object with only non-object keys\n",
       " * we need this to avoid circular references\n",
       " * http://stackoverflow.com/a/24161582/3208463\n",
       " */\n",
       "function simpleKeys(original) {\n",
       "    return Object.keys(original).reduce(function (obj, key) {\n",
       "        if (typeof original[key] !== 'object') {\n",
       "            obj[key] = original[key];\n",
       "        }\n",
       "        return obj;\n",
       "    }, {});\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.mouse_event = function (event, name) {\n",
       "    var canvas_pos = mpl.findpos(event);\n",
       "\n",
       "    if (name === 'button_press') {\n",
       "        this.canvas.focus();\n",
       "        this.canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    var x = canvas_pos.x * mpl.ratio;\n",
       "    var y = canvas_pos.y * mpl.ratio;\n",
       "\n",
       "    this.send_message(name, {\n",
       "        x: x,\n",
       "        y: y,\n",
       "        button: event.button,\n",
       "        step: event.step,\n",
       "        guiEvent: simpleKeys(event),\n",
       "    });\n",
       "\n",
       "    /* This prevents the web browser from automatically changing to\n",
       "     * the text insertion cursor when the button is pressed.  We want\n",
       "     * to control all of the cursor setting manually through the\n",
       "     * 'cursor' event from matplotlib */\n",
       "    event.preventDefault();\n",
       "    return false;\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function (_event, _name) {\n",
       "    // Handle any extra behaviour associated with a key event\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.key_event = function (event, name) {\n",
       "    // Prevent repeat events\n",
       "    if (name === 'key_press') {\n",
       "        if (event.which === this._key) {\n",
       "            return;\n",
       "        } else {\n",
       "            this._key = event.which;\n",
       "        }\n",
       "    }\n",
       "    if (name === 'key_release') {\n",
       "        this._key = null;\n",
       "    }\n",
       "\n",
       "    var value = '';\n",
       "    if (event.ctrlKey && event.which !== 17) {\n",
       "        value += 'ctrl+';\n",
       "    }\n",
       "    if (event.altKey && event.which !== 18) {\n",
       "        value += 'alt+';\n",
       "    }\n",
       "    if (event.shiftKey && event.which !== 16) {\n",
       "        value += 'shift+';\n",
       "    }\n",
       "\n",
       "    value += 'k';\n",
       "    value += event.which.toString();\n",
       "\n",
       "    this._key_event_extra(event, name);\n",
       "\n",
       "    this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n",
       "    return false;\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onclick = function (name) {\n",
       "    if (name === 'download') {\n",
       "        this.handle_save(this, null);\n",
       "    } else {\n",
       "        this.send_message('toolbar_button', { name: name });\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n",
       "    this.message.textContent = tooltip;\n",
       "};\n",
       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n",
       "\n",
       "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n",
       "\n",
       "mpl.default_extension = \"png\";/* global mpl */\n",
       "\n",
       "var comm_websocket_adapter = function (comm) {\n",
       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
       "    // object with the appropriate methods. Currently this is a non binary\n",
       "    // socket, so there is still some room for performance tuning.\n",
       "    var ws = {};\n",
       "\n",
       "    ws.close = function () {\n",
       "        comm.close();\n",
       "    };\n",
       "    ws.send = function (m) {\n",
       "        //console.log('sending', m);\n",
       "        comm.send(m);\n",
       "    };\n",
       "    // Register the callback with on_msg.\n",
       "    comm.on_msg(function (msg) {\n",
       "        //console.log('receiving', msg['content']['data'], msg);\n",
       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
       "        ws.onmessage(msg['content']['data']);\n",
       "    });\n",
       "    return ws;\n",
       "};\n",
       "\n",
       "mpl.mpl_figure_comm = function (comm, msg) {\n",
       "    // This is the function which gets called when the mpl process\n",
       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
       "\n",
       "    var id = msg.content.data.id;\n",
       "    // Get hold of the div created by the display call when the Comm\n",
       "    // socket was opened in Python.\n",
       "    var element = document.getElementById(id);\n",
       "    var ws_proxy = comm_websocket_adapter(comm);\n",
       "\n",
       "    function ondownload(figure, _format) {\n",
       "        window.open(figure.canvas.toDataURL());\n",
       "    }\n",
       "\n",
       "    var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n",
       "\n",
       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
       "    // web socket which is closed, not our websocket->open comm proxy.\n",
       "    ws_proxy.onopen();\n",
       "\n",
       "    fig.parent_element = element;\n",
       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
       "    if (!fig.cell_info) {\n",
       "        console.error('Failed to find cell for figure', id, fig);\n",
       "        return;\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_close = function (fig, msg) {\n",
       "    var width = fig.canvas.width / mpl.ratio;\n",
       "    fig.root.removeEventListener('remove', this._remove_fig_handler);\n",
       "\n",
       "    // Update the output cell to use the data from the current canvas.\n",
       "    fig.push_to_output();\n",
       "    var dataURL = fig.canvas.toDataURL();\n",
       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
       "    // the notebook keyboard shortcuts fail.\n",
       "    IPython.keyboard_manager.enable();\n",
       "    fig.parent_element.innerHTML =\n",
       "        '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
       "    fig.close_ws(fig, msg);\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.close_ws = function (fig, msg) {\n",
       "    fig.send_message('closing', msg);\n",
       "    // fig.ws.close()\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.push_to_output = function (_remove_interactive) {\n",
       "    // Turn the data on the canvas into data in the output cell.\n",
       "    var width = this.canvas.width / mpl.ratio;\n",
       "    var dataURL = this.canvas.toDataURL();\n",
       "    this.cell_info[1]['text/html'] =\n",
       "        '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function () {\n",
       "    // Tell IPython that the notebook contents must change.\n",
       "    IPython.notebook.set_dirty(true);\n",
       "    this.send_message('ack', {});\n",
       "    var fig = this;\n",
       "    // Wait a second, then push the new image to the DOM so\n",
       "    // that it is saved nicely (might be nice to debounce this).\n",
       "    setTimeout(function () {\n",
       "        fig.push_to_output();\n",
       "    }, 1000);\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function () {\n",
       "    var fig = this;\n",
       "\n",
       "    var toolbar = document.createElement('div');\n",
       "    toolbar.classList = 'btn-toolbar';\n",
       "    this.root.appendChild(toolbar);\n",
       "\n",
       "    function on_click_closure(name) {\n",
       "        return function (_event) {\n",
       "            return fig.toolbar_button_onclick(name);\n",
       "        };\n",
       "    }\n",
       "\n",
       "    function on_mouseover_closure(tooltip) {\n",
       "        return function (event) {\n",
       "            if (!event.currentTarget.disabled) {\n",
       "                return fig.toolbar_button_onmouseover(tooltip);\n",
       "            }\n",
       "        };\n",
       "    }\n",
       "\n",
       "    fig.buttons = {};\n",
       "    var buttonGroup = document.createElement('div');\n",
       "    buttonGroup.classList = 'btn-group';\n",
       "    var button;\n",
       "    for (var toolbar_ind in mpl.toolbar_items) {\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) {\n",
       "            /* Instead of a spacer, we start a new button group. */\n",
       "            if (buttonGroup.hasChildNodes()) {\n",
       "                toolbar.appendChild(buttonGroup);\n",
       "            }\n",
       "            buttonGroup = document.createElement('div');\n",
       "            buttonGroup.classList = 'btn-group';\n",
       "            continue;\n",
       "        }\n",
       "\n",
       "        button = fig.buttons[name] = document.createElement('button');\n",
       "        button.classList = 'btn btn-default';\n",
       "        button.href = '#';\n",
       "        button.title = name;\n",
       "        button.innerHTML = '<i class=\"fa ' + image + ' fa-lg\"></i>';\n",
       "        button.addEventListener('click', on_click_closure(method_name));\n",
       "        button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n",
       "        buttonGroup.appendChild(button);\n",
       "    }\n",
       "\n",
       "    if (buttonGroup.hasChildNodes()) {\n",
       "        toolbar.appendChild(buttonGroup);\n",
       "    }\n",
       "\n",
       "    // Add the status bar.\n",
       "    var status_bar = document.createElement('span');\n",
       "    status_bar.classList = 'mpl-message pull-right';\n",
       "    toolbar.appendChild(status_bar);\n",
       "    this.message = status_bar;\n",
       "\n",
       "    // Add the close button to the window.\n",
       "    var buttongrp = document.createElement('div');\n",
       "    buttongrp.classList = 'btn-group inline pull-right';\n",
       "    button = document.createElement('button');\n",
       "    button.classList = 'btn btn-mini btn-primary';\n",
       "    button.href = '#';\n",
       "    button.title = 'Stop Interaction';\n",
       "    button.innerHTML = '<i class=\"fa fa-power-off icon-remove icon-large\"></i>';\n",
       "    button.addEventListener('click', function (_evt) {\n",
       "        fig.handle_close(fig, {});\n",
       "    });\n",
       "    button.addEventListener(\n",
       "        'mouseover',\n",
       "        on_mouseover_closure('Stop Interaction')\n",
       "    );\n",
       "    buttongrp.appendChild(button);\n",
       "    var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n",
       "    titlebar.insertBefore(buttongrp, titlebar.firstChild);\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._remove_fig_handler = function () {\n",
       "    this.close_ws(this, {});\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function (el) {\n",
       "    el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n",
       "    el.addEventListener('remove', this._remove_fig_handler);\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function (el) {\n",
       "    // this is important to make the div 'focusable\n",
       "    el.setAttribute('tabindex', 0);\n",
       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
       "    // off when our div gets focus\n",
       "\n",
       "    // location in version 3\n",
       "    if (IPython.notebook.keyboard_manager) {\n",
       "        IPython.notebook.keyboard_manager.register_events(el);\n",
       "    } else {\n",
       "        // location in version 2\n",
       "        IPython.keyboard_manager.register_events(el);\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function (event, _name) {\n",
       "    var manager = IPython.notebook.keyboard_manager;\n",
       "    if (!manager) {\n",
       "        manager = IPython.keyboard_manager;\n",
       "    }\n",
       "\n",
       "    // Check for shift+enter\n",
       "    if (event.shiftKey && event.which === 13) {\n",
       "        this.canvas_div.blur();\n",
       "        // select the cell after this one\n",
       "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
       "        IPython.notebook.select(index + 1);\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_save = function (fig, _msg) {\n",
       "    fig.ondownload(fig, null);\n",
       "};\n",
       "\n",
       "mpl.find_output_cell = function (html_output) {\n",
       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
       "    // IPython event is triggered only after the cells have been serialised, which for\n",
       "    // our purposes (turning an active figure into a static one), is too late.\n",
       "    var cells = IPython.notebook.get_cells();\n",
       "    var ncells = cells.length;\n",
       "    for (var i = 0; i < ncells; i++) {\n",
       "        var cell = cells[i];\n",
       "        if (cell.cell_type === 'code') {\n",
       "            for (var j = 0; j < cell.output_area.outputs.length; j++) {\n",
       "                var data = cell.output_area.outputs[j];\n",
       "                if (data.data) {\n",
       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
       "                    data = data.data;\n",
       "                }\n",
       "                if (data['text/html'] === html_output) {\n",
       "                    return [cell, data, j];\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    }\n",
       "};\n",
       "\n",
       "// Register the function which deals with the matplotlib target/channel.\n",
       "// The kernel may be null if the page has been refreshed.\n",
       "if (IPython.notebook.kernel !== null) {\n",
       "    IPython.notebook.kernel.comm_manager.register_target(\n",
       "        'matplotlib',\n",
       "        mpl.mpl_figure_comm\n",
       "    );\n",
       "}\n"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<img src=\"\" width=\"1499.6833333333334\">"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from loss import inverse_model, direct_model\n",
    "from data import domain\n",
    "import jax.numpy as jnp\n",
    "import numpy as np\n",
    "\n",
    "inverse_params = agent.params[1]\n",
    "x_test = jnp.linspace(*domain[:, 0], 2000).reshape((-1, 1))\n",
    "a_fn = lambda x: 1+2/np.pi*np.cos(2*np.pi*x)\n",
    "a_pred = inverse_model(inverse_params, x_test)\n",
    "a_true = a_fn(x_test)\n",
    "\n",
    "direct_params = agent.params[0]\n",
    "t_test = domain[1, 1]*jnp.ones_like(x_test)\n",
    "uv_pred = direct_model(direct_params, jnp.hstack([x_test, t_test]))\n",
    "\n",
    "from scipy.io import loadmat\n",
    "data_true = loadmat(\"problem2_2_snapshot_epsilon_0.7.mat\")\n",
    "u_true, v_true = data_true[\"u_snapshots\"][:, -1], data_true[\"v_snapshots\"][:, -1]\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib notebook\n",
    "\n",
    "f, ax = plt.subplots(1, 3, figsize = (15, 5))\n",
    "ax[0].plot(x_test, a_pred, label = \"pred\")\n",
    "ax[0].plot(x_test, a_true, label = \"true\")\n",
    "ax[0].set_title(\"a\")\n",
    "ax[1].plot(x_test, uv_pred[:, 0:1], label = \"pred\")\n",
    "ax[1].plot(x_test, u_true, label = \"true\")\n",
    "ax[1].set_title(\"u\")\n",
    "ax[2].plot(x_test, uv_pred[:, 1:2], label = \"pred\")\n",
    "ax[2].plot(x_test, v_true, label = \"true\")\n",
    "ax[2].set_title(\"v\")\n",
    "for ax_ in ax:\n",
    "\tax_.legend()\n",
    "\tax_.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "agent.params[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
